﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
using Configuration.ServerApi.Param;
using Configuration.ServerApi.Service;
using System.Threading.Tasks;

namespace Configuration.ServerApi.Controllers
{
    /// <summary>
    /// 设备相关Controller
    /// </summary>
    [Authorize("AuthJwt")]
    [Route("api/[controller]")]
    [ApiController]
    public class DeviceController : ControllerBase
    {
        private readonly IHostEnvironment HostEnvironment;
        private readonly IDeviceService DeviceService;

        #region 构造函数

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="hostEnvironment"></param>
        /// <param name="deviceService"></param>
        public DeviceController(IHostEnvironment hostEnvironment,
            IDeviceService deviceService)
        {
            HostEnvironment = hostEnvironment;
            DeviceService = deviceService;
        }

        #endregion

        #region 获取所有节点数据

        /// <summary>
        /// 获取所有节点数据
        /// </summary>
        /// <param name="param">搜索条件</param>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetAllNodeData")]
        public async Task<IActionResult> GetAllNodeData(SearchModel param)
        {
            return await DeviceService.GetAllNodeData(param);
        }

        #endregion

        #region 获取节点配置详情

        /// <summary>
        /// 获取节点配置详情
        /// </summary>
        /// <param name="param">搜索条件</param>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("NodeDataDetail")]
        public async Task<IActionResult> NodeDataDetail(SearchModel param)
        {
            return await DeviceService.NodeDataDetail(param);
        }

        #endregion

        #region 写入指定节点数据

        /// <summary>
        /// 写入指定节点数据
        /// </summary>
        /// <param name="param">更新参数集</param>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("SetNodeData")]
        public async Task<IActionResult> SetNodeData(UpdateModel param)
        {
            return await DeviceService.SetNodeData(param);
        }

        #endregion

        #region 获取全部设备运行状态

        /// <summary>
        /// 获取全部设备运行状态
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("AllDeviceStatusData")]
        public async Task<IActionResult> AllDeviceStatusData()
        {
            return await DeviceService.AllDeviceStatusData();
        }

        #endregion

        #region 获取AGV小车状态详情

        /// <summary>
        /// 获取AGV小车状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetAutoGuideVehicleStatus")]
        public async Task<IActionResult> GetAutoGuideVehicleStatus()
        {
            return await DeviceService.GetAutoGuideVehicleStatus();
        }

        #endregion

        #region 获取球磨机状态详情

        /// <summary>
        /// 获取球磨机状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetBallMillingStationStatus")]
        public async Task<IActionResult> GetBallMillingStationStatus()
        {
            return await DeviceService.GetBallMillingStationStatus();
        }

        #endregion

        #region 获取管式炉状态详情

        /// <summary>
        /// 获取管式炉状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetTubeFurnaceStationStatus")]
        public async Task<IActionResult> GetTubeFurnaceStationStatus()
        {
            return await DeviceService.GetTubeFurnaceStationStatus();
        }

        #endregion

        #region 获取下装炉状态详情

        /// <summary>
        /// 获取下装炉状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetBottomFurnaceStationStatus")]
        public async Task<IActionResult> GetBottomFurnaceStationStatus()
        {
            return await DeviceService.GetBottomFurnaceStationStatus();
        }

        #endregion

        #region 获取开盖机状态详情

        /// <summary>
        /// 获取开盖机状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetCapperStationStatus")]
        public async Task<IActionResult> GetCapperStationStatus()
        {
            return await DeviceService.GetCapperStationStatus();
        }

        #endregion

        #region 获取坩埚转换位状态详情

        /// <summary>
        /// 获取坩埚转换位状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetCrucibleConversionStationStatus")]
        public async Task<IActionResult> GetCrucibleConversionStationStatus()
        {
            return await DeviceService.GetCrucibleConversionStationStatus();
        }

        #endregion

        #region 获取破碎机状态详情

        /// <summary>
        /// 获取破碎机状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetCrusherStationStatus")]
        public async Task<IActionResult> GetCrusherStationStatus()
        {
            return await DeviceService.GetCrusherStationStatus();
        }

        #endregion

        #region 获取电化学测试仪状态详情

        /// <summary>
        /// 获取电化学测试仪状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetElectroChemistryTestingStationStatus")]
        public async Task<IActionResult> GetElectroChemistryTestingStationStatus()
        {
            return await DeviceService.GetElectroChemistryTestingStationStatus();
        }

        #endregion

        #region 获取高通量配粉设备状态详情

        /// <summary>
        /// 获取高通量配粉设备状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetFlourBlendingStationStatus")]
        public async Task<IActionResult> GetFlourBlendingStationStatus()
        {
            return await DeviceService.GetFlourBlendingStationStatus();
        }

        #endregion

        #region 获取ROBOT机器人状态详情

        /// <summary>
        /// 获取ROBOT机器人状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetJakaRobotStatus")]
        public async Task<IActionResult> GetJakaRobotStatus()
        {
            return await DeviceService.GetJakaRobotStatus();
        }

        #endregion

        #region 获取磁力搅拌捏片蠕动设备状态详情

        /// <summary>
        /// 获取磁力搅拌捏片蠕动设备状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetMagneticPeristalticOthersStationStatus")]
        public async Task<IActionResult> GetMagneticPeristalticOthersStationStatus()
        {
            return await DeviceService.GetMagneticPeristalticOthersStationStatus();
        }

        #endregion

        #region 获取烘箱设备状态详情

        /// <summary>
        /// 获取烘箱设备状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetOvenStationStatus")]
        public async Task<IActionResult> GetOvenStationStatus()
        {
            return await DeviceService.GetOvenStationStatus();
        }

        #endregion

        #region 获取封装机状态详情

        /// <summary>
        /// 获取封装机状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetPackagingStationStatus")]
        public async Task<IActionResult> GetPackagingStationStatus()
        {
            return await DeviceService.GetPackagingStationStatus();
        }

        #endregion

        #region 获取压片机状态详情

        /// <summary>
        /// 获取压片机状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetTabletPressStationStatus")]
        public async Task<IActionResult> GetTabletPressStationStatus()
        {
            return await DeviceService.GetTabletPressStationStatus();
        }

        #endregion

        #region 获取移液配比设备状态详情

        /// <summary>
        /// 获取移液配比设备状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetPipetteDistributionStationStatus")]
        public async Task<IActionResult> GetPipetteDistributionStationStatus()
        {
            return await DeviceService.GetPipetteDistributionStationStatus();
        }

        #endregion

        #region 获取刷料机设备状态详情

        /// <summary>
        /// 获取刷料机设备状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetScrapingStationStatus")]
        public async Task<IActionResult> GetScrapingStationStatus()
        {
            return await DeviceService.GetScrapingStationStatus();
        }

        #endregion

        #region 获取固液测试设备状态详情

        /// <summary>
        /// 获取固液测试设备状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetSolidLiquidTestingStationStatus")]
        public async Task<IActionResult> GetSolidLiquidTestingStationStatus()
        {
            return await DeviceService.GetSolidLiquidTestingStationStatus();
        }

        #endregion

        #region 获取固固测试设备状态详情

        /// <summary>
        /// 获取固固测试设备状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetSolidSolidTestingStationStatus")]
        public async Task<IActionResult> GetSolidSolidTestingStationStatus()
        {
            return await DeviceService.GetSolidSolidTestingStationStatus();
        }

        #endregion

        #region 获取XRD测试设备状态详情

        /// <summary>
        /// 获取XRD测试设备状态详情
        /// </summary>
        /// <returns>JSON结果集</returns>
        [HttpPost]
        [Route("GetXRDTestingStationStatus")]
        public async Task<IActionResult> GetXRDTestingStationStatus()
        {
            return await DeviceService.GetXRDTestingStationStatus();
        }

        #endregion

    }
}
